import aaa.Data;
import aaa.JavaFileObjectImpl;
import sun.tools.jar.JarException;
import sun.tools.jar.Main;

import javax.tools.*;
import java.lang.reflect.InvocationTargetException;
import java.net.MalformedURLException;
import java.util.*;
public class Test {

    public static void main(String[] args) throws MalformedURLException, ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException {
//        File file1 =  new File("C:\\Users\\aye\\Downloads\\源码\\源码\\untitled\\class");
//        System.out.println(file1.);
//        URLClassLoader classloader = (URLClassLoader) ClassLoader.getSystemClassLoader();
//        Method add = URLClassLoader.class.getDeclaredMethod("addURL", new Class[] { URL.class });
//        add.setAccessible(true);
//        add.invoke(classloader, new Object[] { file1.toURI().toURL() });




//        Codec<School> schoolCodec = ProtobufProxy.create(School.class);



//        URL fileUrl = new File("C:\\Users\\aye\\Downloads\\源码\\源码\\untitled\\class").toURI().toURL();
//        URLClassLoader urlClassLoader = new URLClassLoader(new URL[]{fileUrl},JdkCompiler.class.getClassLoader());
//
//        Class<?> school = urlClassLoader.loadClass("School");
//        Class<?> aClass = urlClassLoader.loadClass("javax.management.Descriptor");
//        Codec schoolCodec = ProtobufProxy.create(School2.class);
//        Codec schoolCodec2 = ProtobufProxy.create(school);



        JavaCompiler systemJavaCompiler = ToolProvider.getSystemJavaCompiler();
        JavaCompiler jdkCompiler =  ToolProvider.getSystemJavaCompiler();;

        String className="School$$JProtoBufClass";

        JavaFileObjectImpl javaFileObject = new JavaFileObjectImpl(className, Data.sourceCode);

        jdkCompiler.getTask(null, null, null, Data.options, null,
                Arrays.asList(new JavaFileObject[] { javaFileObject })).call();

//        jdkCompiler.getTask(null, null, null, null, null,
//                Arrays.asList(new JavaFileObject[] { javaFileObject })).call();

        DiagnosticCollector<JavaFileObject> diagnosticCollector = new DiagnosticCollector<JavaFileObject>();
    }
}
